/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package commands;

import java.util.concurrent.ConcurrentHashMap;

/**
 *
 * @author SafarTimuro
 */
public class CommandFactory {
    static ConcurrentHashMap<String, CommandDef> cmdMap;
    
    public CommandFactory(){
        if(cmdMap == null){
            cmdMap = new ConcurrentHashMap<String, CommandDef>(100, 0.80f);
            updateCommands();
        }
    }
    
    private void updateCommands(){
        cmdMap.clear();
        //mapCommand();
    }
    
    private void mapCommand(ConcurrentHashMap<String, CommandDef> map, 
            CommandDef cDef) {
        map.put(cDef.getPrimaryVerb(), cDef);
        String[] aliases = cDef.getAliasVerbs();
        //Map all the aliases
        for(int i = 0; i < aliases.length; ++i){
            map.put(aliases[i], cDef);
        }
    }
}
